package io.renren.modules.sys.service.impl;

import io.renren.common.utils.Result;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.PocketTemplateDao;
import io.renren.modules.sys.entity.PocketTemplateEntity;
import io.renren.modules.sys.service.PocketTemplateService;


/**
 * 账目模板impl
 *
 * @author Amadeus
 * @date 2020/12/30
 */
@Service("pocketTemplateService")
public class PocketTemplateServiceImpl extends ServiceImpl<PocketTemplateDao, PocketTemplateEntity> implements PocketTemplateService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<PocketTemplateEntity> page = this.page(
                new Query<PocketTemplateEntity>().getPage(params),
                new QueryWrapper<PocketTemplateEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public Result savePocket(PocketTemplateEntity template) {

        return this.save(template) ? Result.success() : Result.failure("新增失败");
    }

    @Override
    public Result updatePocket(PocketTemplateEntity template) {

        return this.saveOrUpdate(template) ? Result.success() : Result.failure("修改失败");
    }

}